package cn.wh.controller;

import cn.wh.service.IIndexService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

@Controller
public class IndexController {

    @Autowired
    IIndexService indexService;
    private final static Logger log = LoggerFactory.getLogger(IndexController.class);

    @RequestMapping("/index")
    @ResponseBody
    public String index(){
        if(log.isDebugEnabled()){
            log.debug("enter index() :{}",indexService.getUserCount());
        }
        log.warn("  warn index() :{}","王浩");
        log.info("  info index() :{}","王浩");
        log.debug(" debug index() :{}","王浩");
        log.error(" error index() :{}","王浩");
        return "index";
    }

    @RequestMapping("/test")
    public String test(HttpServletRequest request){
        request.setAttribute("count",indexService.getUserCount());
        return "index";
    }

}
